﻿@model PsCommand

@{
    ViewBag.Title = "คำสั่งให้ออกราชการ";
}

<div style="margin-left:100px; margin-bottom: 30px; float:left;">
<h2><span class="green">เพิ่ม</span> คำสั่งให้ออกราชการ</h2>

@using (Html.BeginForm()) {
    @*@Html.AntiForgeryToken()*@
    @Html.ValidationSummary(true)

    <h4 class="header">แบบฟอร์มคำสั่งให้ออกราชการ</h4>

    <div class="detail">
        <table class="info">
            <tr>
                <td class="editor-label">

                </td>
                <td class="editor-field">
                    @Html.RadioButtonFor(model => model.CmdFlag, "1") คำสั่งหน่วยงาน
                    @Html.RadioButtonFor(model => model.CmdFlag, "2") คำสั่งภายใน
                    @Html.RadioButtonFor(model => model.CmdFlag, "3") คำสั่งกระทรวง
                    @Html.ValidationMessageFor(model => model.CmdFlag)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.CmdTypeId)
                </td>
                <td class="editor-field">
                    @(Html.Telerik().ComboBoxFor(m => m.CmdTypeId)
                        .BindTo(new SelectList(new GERPContext(true).PsCommandTypes.Where(m => m.CmdTypeId != 1700 && (m.CmdGroupId  == 6) && m.RecordStatus != "D").ToList(), "CmdTypeId", "CmdTypeName"))
                        //.SelectedIndex(Model != null ? (Model.CmdTypeId != null ? Model.CmdTypeId.Value : -1) : -1)
                        .HighlightFirstMatch(true)
                        .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                    )
                    @Html.ValidationMessageFor(model => model.CmdTypeId)
                </td>
            </tr>

            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.CmdName)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.CmdName)
                    @Html.ValidationMessageFor(model => model.CmdName)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.CmdRefNo)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.CmdRefNo)
                    @Html.ValidationMessageFor(model => model.CmdRefNo)
                </td>
            </tr>

            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.CmdDescr)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.CmdDescr)
                    @Html.ValidationMessageFor(model => model.CmdDescr)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.EmpTypeId)
                </td>
                <td class="editor-field">
                    @(Html.Telerik().ComboBoxFor(m => m.EmpTypeId)
                        .BindTo(new SelectList(new GERPContext(true).MasEmployeeTypes.Where(m => m.RecordStatus != "D").ToList(), "EmpTypeId", "Name"))
                        //.SelectedIndex(Model != null ? (Model.EmpTypeId != null ? Model.EmpTypeId.Value : -1) : -1)
                        .HighlightFirstMatch(true)
                        .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                    )
                    @Html.ValidationMessageFor(model => model.EmpTypeId)
                </td>
            </tr>

            @*<tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.PenaltyId)
                </td>
                <td class="editor-field">
                    @(Html.Telerik().ComboBoxFor(m => m.PenaltyId)
                        .BindTo(new SelectList(new GERPContext(true).hrm_dc_penalty.ToList(), "pen_seq", "pen_name"))
                        //.SelectedIndex(Model != null ? (Model.PenaltyId != null ? Model.PenaltyId.Value : -1) : -1)
                        .HighlightFirstMatch(true)
                        .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                    )
                    @Html.ValidationMessageFor(model => model.PenaltyId)
                </td>
            </tr>*@
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.Remarks)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.Remarks)
                    @Html.ValidationMessageFor(model => model.Remarks)
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <h3>หัวรายงาน</h3>
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.CmdRptDate)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.CmdRptDate)
                    @Html.ValidationMessageFor(model => model.CmdRptDate)
                </td>
            </tr>
            <tr>
                <td class="editor-label">
                    @Html.LabelFor(model => model.RptHeader)
                </td>
                <td class="editor-field">
                    @Html.EditorFor(model => model.RptHeader)
                    @Html.ValidationMessageFor(model => model.RptHeader)
                </td>
            </tr>
        </table>
        
    <p id="pnlCommand1">
        <input type="submit" value="บันทึก" />&nbsp;&nbsp;@Html.ActionLink("ย้อนกลับ", "Index")
    </p>
    </div>
}
    
</div>

@section Scripts {
    @*@Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryui")
    @Styles.Render("~/Content/themes/base/css")*@

    <script type="text/javascript" >
        jQuery(function ($) {
            $("input#approved_type").change(function () {
                $("#divApproverInternal").toggle(this.value == "1");
                $("#divApproverExternal").toggle(this.value == "2");
            });
            $("input#approved_type:checked").change();
        });

        function ddlApprovedChange(e) {
            $.getJSON('@Url.Action("GetPosition", "Employee")', { 'id': e.value }, function (data) {
                $("input#approved_positions").val(data.pos_name);
            });
        }

        jQuery(function ($) {
            $("[type='submit']").click(function () {
                var ans = confirm("ต้องการบันทึก ใช่หรือไม่?");

                if (!ans) return false;
            })
        })

        jQuery(function ($) {
            $(".datepicker").datepicker({
                showOn: "focus",
                buttonImage: "../../Images/Icons/calendar.png",
                buttonImageOnly: true,
                dateFormat: "dd/mm/yy",
                isBE: true
            });
        });
    </script>
}
